﻿using System;
using System.Linq;
using System.Collections.Generic;
using NakedObjects;
using NakedObjects.Value;

namespace HRMDomain
{
    public class Meeting:Base
    {

        [Mask("d")]
        public virtual DateTime DatePerformed { get; set; }
        [Mask("d")]
        public virtual DateTime ReviewBy { get; set; }
        [Mask("d")]
        public virtual DateTime ReviewedOn { get; set; }

        #region Documents (collection)
        private ICollection<Document> _Documents = new List<Document>();

        public virtual ICollection<Document> Documents
        {
            get
            {
                return _Documents;
            }
            set
            {
                _Documents = value;
            }
        }
        #endregion
        #region AddDocument (Action)

        [MemberOrder(Sequence = "1")]
        public void AddDocument(string Name, FileAttachment file)
        {
            Document newdoc = Container.NewTransientInstance<Document>();
            newdoc.Name = Name;
            newdoc.Data = file.GetResourceAsByteArray();
            newdoc.MIMEType = file.MimeType;

            Container.Persist<Document>(ref newdoc);

            Documents.Add(newdoc);
            Container.InformUser("Document Attachment Added.");

        }

        // Use 'hide', 'dis', 'val', 'actdef', 'actcho' shortcuts to add supporting methods here.
        #endregion
        #region Notes (collection)
        private ICollection<Note> _Notes = new List<Note>();

        public virtual ICollection<Note> Notes
        {
            get
            {
                return _Notes;
            }
            set
            {
                _Notes = value;
            }
        }

        public void AddToNotes(Note value)
        {
            if (!(_Notes.Contains(value)))
            {
                _Notes.Add(value);
            }
        }

        public void RemoveFromNotes(Note value)
        {
            if (_Notes.Contains(value))
            {
                _Notes.Remove(value);
            }
        }

        public IList<Note> Choices0RemoveFromNotes()
        {
            return _Notes.ToList();
        }
        #endregion

        #region AddNote (Action)

        [MemberOrder(Sequence = "1")]
        public void AddNote([MultiLine]string Entry)
        {
            Note newNote = Container.NewTransientInstance<Note>();

            newNote.EnteredDate = DateTime.Now;
            newNote.Text = Entry;
            Container.Persist<Note>(ref newNote);
            if (!(_Notes.Contains(newNote)))
            {
                _Notes.Add(newNote);
            }
            Container.InformUser("New Note Added.");

        }

        // Use 'hide', 'dis', 'val', 'actdef', 'actcho' shortcuts to add supporting methods here.
        #endregion
    }
}
